Page({
  data: {
    bgd113: "",
    bgd114: "",
    bgd115: "",
    bgd116: "",
    bgd117: "",
    bgd118: "",
    bgd119: "",
    bgd120: "",
    bgd121: "",
    bgd122: "",
    bgd123: "",
    bgd124: "",
    bgd125: "",
    bgd126: "",
    bgd127: "",
    bgd128: "",
    bgd129: "",
    bgd130: "",
    bgd131: "",
    bgd132: "",
    bgd133: "",
    bgd134: "",
    bgd135: "",
    bgd136: "",
    bgd137: "",
    bgd138: "",
    bgd139: "",
    bgd140: "",
  },
  onLoad: function () {
    console.log("order进来");
    //wx.clearStorage();
    var that = this;
    wx.request({
      url: 'https://www.szz5.com/admin/selectAll',
      method: 'POST',
      data: {},
      success: function (res) {
        console.info("++++++++++=1", JSON.stringify(res));
        var list = res.data;
        console.info("++++++++++=2", JSON.stringify(list));
        if (list != null) {
          for (var index in list) {
            console.info("++++++++++=3", list[index]);
            var bathid = list[index];
            if (bathid == '113') {
              console.info("进来001");
              that.setData({
                bgd113: "red"
              });
            }
            if (bathid == "114") {
              console.info("进来002");
              that.setData({
                bgd114: "red"
              });
            }
            if (bathid == "115") {
              that.setData({
                bgd115: "red"
              });
            }
            if (bathid == "116") {
              that.setData({
                bgd116: "red"
              });
            }
            if (bathid == "117") {
              that.setData({
                bgd117: "red"
              });
            }
            if (bathid == "118") {
              that.setData({
                bgd118: "red"
              });
            }
            if (bathid == "119") {
              that.setData({
                bgd119: "red"
              });
            }
            if (bathid == "120") {
              that.setData({
                bgd120: "red"
              });
            }
            if (bathid == "121") {
              that.setData({
                bgd121: "red"
              });
            }
            if (bathid == "122") {
              that.setData({
                bgd122: "red"
              });
            }
            if (bathid == "123") {
              that.setData({
                bgd123: "red"
              });
            }
            if (bathid == "124") {
              that.setData({
                bgd124: "red"
              });
            }
            if (bathid == "125") {
              that.setData({
                bgd125: "red"
              });
            }
            if (bathid == "126") {
              that.setData({
                bgd126: "red"
              });
            }
            if (bathid == "127") {
              that.setData({
                bgd127: "red"
              });
            }
            if (bathid == "128") {
              that.setData({
                bgd128: "red"
              });
            }
            if (bathid == "129") {
              that.setData({
                bgd129: "red"
              });
            }
            if (bathid == "130") {
              that.setData({
                bg130: "red"
              });
            }
            if (bathid == "131") {
              that.setData({
                bgd131: "red"
              });
            }
            if (bathid == "132") {
              that.setData({
                bgd132: "red"
              });
            }
            if (bathid == "133") {
              that.setData({
                bgd133: "red"
              });
            }
            if (bathid == "134") {
              that.setData({
                bgd134: "red"
              });
            }
            if (bathid == "135") {
              that.setData({
                bgd135: "red"
              });
            }
            if (bathid == "136") {
              that.setData({
                bgd136: "red"
              });
            }
            if (bathid == "137") {
              that.setData({
                bgd137: "red"
              });
            }
            if (bathid == "138") {
              that.setData({
                bgd138: "red"
              });
            }
            if (bathid == "139") {
              that.setData({
                bgd139: "red"
              });
            }
            if (bathid == "140") {
              that.setData({
                bgd140: "red"
              });
            }
          }

          // wx.showToast({
          //   title: '获取数据失败',      
          //   duration: 1500      
          // })
        }
      }
    })
  },
  gotoresult: function (e) {
    var ID = e.currentTarget.id;
    console.log("idd", ID);
    // wx.clearStorage("userInfo");
    var stor = wx.getStorageSync("userInfo");
    var getkey = wx.getStorageSync("key1");
    if (stor == null || stor == "") {
      console.log("stor" + stor);
      wx.showModal({
        title: '提示',
        content: '您没有激活状态，请去激活',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');

            wx.hideToast()
            wx.switchTab({
              url: '../../login/login'
            })

            console.log('1');
            // return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })
    } else if (getkey) {
      wx.showModal({
        title: '提示',
        content: '您已经选择过！',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })

    } else {

      wx.request({
        url: 'https://www.szz5.com/admin/byBathId',
        method: 'POST',
        data: { bathId: ID },
        success: function (res) {
          console.info("++++++++++=4", JSON.stringify(res));
          if (res.data == '1') {
            wx.showModal({
              title: '提示',
              content: '此澡位已被预订！',
              success: function (res) {
                if (res.confirm) {
                  console.log('用户点击确定');
                  return;
                } else if (res.cancel) {
                  console.log('用户点击取消');
                  return;
                }
              }
            })
          }
        }

      })
      wx.showModal({
        title: '提示',
        content: '是否预定该位置',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            wx.setStorageSync("keykey", ID);
            wx.navigateTo({
              url: '../../seltime/seltime',
            })
            return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })

    }
    // wx.getStorage({
    //   key: 'key',
    //   success: function (res) {
    //     console.log(res.data);
    //     if(res){
    //       console.log(res);

    //       return;
    //     }
    //   },
    // });



  }



})